package cn.bdqn.layui.mapper;

import cn.bdqn.layui.entity.Role;
import cn.bdqn.layui.entity.User;
import cn.bdqn.layui.entity.vo.UserVO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface UserMapper {

    User findByUserName(@Param("userName") String userName, @Param("id") Integer id);

    @Select("SELECT * FROM `role` r,`user_role` ur WHERE r.`id`=ur.`rid` AND ur.`uid`=#{uid}")
    List<Role> getRolesById(Integer uid);

    List<User> findUserList(@Param("pageNo") Integer pageNo, @Param("pageSize") Integer pageSize,
                            @Param("id") Integer id, @Param("userName") String userName);

    int findUserCount(@Param("id") Integer id, @Param("userName") String userName);

    int addUser(UserVO userVO);

    int addUserRole(Integer uid,Integer rid);

    @Delete("DELETE FROM `user` WHERE id=#{id}")
    int delUser(String id);

    /*@Update("UPDATE `user` SET\n" +
            "  `username` = #{username},\n" +
            "  `password` = #{password} \n" +
            "WHERE `id` = #{id}")*/
    int updateUser(UserVO userVO);

    int deleteUserRole(Integer id);

     List<UserVO> findByUid(Integer uid);

     List<UserVO> findByBangKe(Integer bangkeStatic);

     int updateUserBangkeStatus(@Param("bangkeStatic") Integer bangkeStatic, @Param("id") Integer id);

     //int delUser(Integer id);
}
